﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SMTC.Model.Domain;
using System.Data.Common;
using IMPlant.Core.Data.Unity;
using System.Data;
using SMTC.Model.Model;

namespace SMTC.Dao.HolidayMangement
{
    public class HolidayQueryDao : BaseDao
    {
        private const string SQL_SELECT_HOLIDAY = @"SELECT HolidayDate,
	                                                Discrib,
	                                                ModifyPerson,
	                                                ModifyTime	FROM dbo.SMT_Holiday";

        private const string SQL_SELECT_HOLIDAY_SINGLE = @"SELECT HolidayDate,
	                                                               Discrib,
	                                                               ModifyPerson,
	                                                               ModifyTime FROM dbo.SMT_Holiday
                                                            WHERE DATEDIFF(DAY,HolidayDate,@HolidayDate) = 0";
        /// <summary>
        /// 获取holiday的list
        /// </summary>
        /// <returns></returns>
        public List<SMT_HolidayModel> GetHolidayList()
        {
            return DBTemplete.ExcuteGetList<SMT_HolidayModel>(CommandType.Text, SQL_SELECT_HOLIDAY);
        }

        public SMT_HolidayModel GetHoliday(DateTime dt)
        {
            DbParameter[] parameters =
            {
                DBparameterBuild.Build("@HolidayDate",dt)
            };
            return DBTemplete.ExcuteGetObject<SMT_HolidayModel>(CommandType.Text, SQL_SELECT_HOLIDAY_SINGLE, parameters);
        }
    }
}
